﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem2
{
    class Tablero
    {
        int[][] tablero;
        int largo = 10;
        int ancho = 6;
        public Tablero()
        {
            tablero = new int[largo][];
            for (int i = 0; i < tablero.Length; i++)
            {
                tablero[i] = new int[ancho];
                for (j = 0; j < tablero[i].Length; j++)
                {
                    tablero[i][j] = 0;
                }
            }

        }

        public bool putFicha(figura fig, coordenadas coord)
        {
            if (fig.getLengthH + coord.GetX() + 1 > ancho || fig.getLengthV + coord.GetY() + 1 > largo)
                return false;
            else
            {
                for (int i = 0; i < fig.getLengthV; i++)
                    for (int j = 0; j < fig.getLengthH; j++)
                        if (tablero[coord.GetY() + i][coord.GetX() + j] > 0 && fig.getMatrix()[i][j] > 0)
                            return false;
                for (int i = 0; i < fig.getLengthV; i++)
                    for (int j = 0; j < fig.getLengthH; j++)
                        if (fig.getMatrix()[i][j] > 0)
                            tablero[coord.GetY() + i][coord.GetX() + j] = fig.getMatrix()[i][j];
                return true;
            }
        }


        public void pullFicha(figura fig, coordenadas coord)
        {
            for (int i = 0; i < fig.getLengthV; i++)
                for (int j = 0; j < fig.getLengthH; j++)
                    if (fig.getMatrix()[i][j] > 0)
                        tablero[coord.GetY() + i][coord.GetX() + j] = 0;
        }
    }
}
